﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using nvn.Core.MVP;
using Hutech.CRM.Library.Views;
using Hutech.CRM.Library.Models.Entities;
using Hutech.CRM.Library.Utilities;
using nvn.Library.Patterns;
using System.Drawing;


namespace Hutech.CRM.Web.Controls.ManageCustomers
{
    public partial class AddAndViewCustomer : System.Web.UI.UserControl,IAddAndViewCustomerView
    {
        #region MEMBER VARIABLES
        //protected string EditPropertiesImage = "~/Data/SiteImages/" + WebConfigSettings.EditPropertiesImage;
        //protected string DeleteLinkImage = "~/Data/SiteImages/" + WebConfigSettings.DeleteLinkImage;
        //List<TowTypeParameters<Guid, string>> _GroupLevelCustomers;
        #endregion

        protected override void OnInit(EventArgs e)
        {
            base.OnInit(e);
            this.InitView();

            this.ImageButtonSave.Click += new ImageClickEventHandler(ImageButtonSave_Click);
            this.ImageButtonBack.Click += new ImageClickEventHandler(ImageButtonBack_Click);
        }

        
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
                OnFristLoadEventHandler();
        }

        void ImageButtonBack_Click(object sender, ImageClickEventArgs e)
        {
            OnCancel_Click();
        }

        void ImageButtonSave_Click(object sender, ImageClickEventArgs e)
        {
            AccountCustomer item = new AccountCustomer();
            item.HoTen = TextBoxName.Text;
            item.DiaChi = TextBoxAddress.Text;
            item.Email = TextBoxEmail.Text;
            item.DienThoai = TextBoxPhoneNumber.Text;
            item.Fax = TextBoxFax.Text;
            item.TaiKhoanNganHang = TextBoxBankAccount.Text;
            item.MaSoThue = TextBoxMST.Text;

            OnSave_Click(item);
        }


        #region Implement from View class
        #region Property

        public string ErrorMessage
        {
            set
            {
                if (value != null)
                    ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "Show", "<script type='text/javascript'>alert('" + value + "');</script>", false);
            }
        }
        #endregion

        #region Event
        public event EventHandler<EventArgs> FristLoadEventHandler;
        private void OnFristLoadEventHandler()
        {
            if (FristLoadEventHandler != null)
                FristLoadEventHandler(this, new EventArgs());
        }

        public event EventHandler<SaveEventAgrs<AccountCustomer>> Save_Click;
        private void OnSave_Click(AccountCustomer myType)
        {
            if (Save_Click != null)
                Save_Click(this, new SaveEventAgrs<AccountCustomer>(myType));
        }

        public event EventHandler<EventArgs> Cancel_Click;
        private void OnCancel_Click()
        {
            if (Cancel_Click != null)
                Cancel_Click(this, new EventArgs());
        }
        #endregion
        #endregion 
        
    

    }
}